using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL {

/// <summary>
/// The UserContactTableManager class is responsible for managing BO.UserContactTable objects in the system.
/// </summary>
[DataObjectAttribute()]
public class UserContactTableManager
  {

#region "Public Methods"

/// <summary>
/// Gets a list with all UserContactTable objects in the database.
/// </summary>
/// <returns>A list with all UserContactTable from the database when the database contains any, or null otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, true)]
public static UserContactTableList GetList(){
return UserContactTableDB.GetList();
}

/// <summary>
/// Gets a single UserContactTable from the database without its data.
/// </summary>
/// <param name="userContactKey">The UserContactKey of the UserContactTable in the database.</param>
/// <returns>A UserContactTable object when the UserContactKey exists in the database, or <see langword="null"/> otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static UserContactTable GetItem(int userContactKey){
return GetItem(userContactKey, false);
}

/// <summary>
/// Gets a single UserContactTable from the database.
/// </summary>
/// <param name="userContactKey">The UserContactKey of the UserContactTable in the database.</param>
/// <param name="getUserContactTableRecords">Determines whether to load all associated UserContactTable records as well.</param>
/// <returns>
/// A UserContactTable object when the UserContactKey exists in the database, or <see langword="null"/> otherwise.
/// </returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static UserContactTable GetItem(int userContactKey, bool getUserContactTableRecords){
UserContactTable myUserContactTable = UserContactTableDB.GetItem(userContactKey);
return myUserContactTable;
}

/// <summary>
/// Saves a UserContactTable in the database.
/// </summary>
/// <param name="myUserContactTable">The UserContactTable instance to save.</param>
/// <returns>The new UserContactKey if the UserContactTable is new in the database or the existing UserContactKey when an item was updated.</returns>
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static int Save(UserContactTable myUserContactTable){
using (TransactionScope myTransactionScope = new TransactionScope()){
int userContactTableUserContactKey = UserContactTableDB.Save(myUserContactTable);

//  Assign the UserContactTable its new (or existing UserContactKey).
myUserContactTable.UserContactKey = userContactTableUserContactKey;

myTransactionScope.Complete();

return userContactTableUserContactKey;
}
}

/// <summary>
/// Deletes a UserContactTable from the database.
/// </summary>
/// <param name="myUserContactTable">The UserContactTable instance to delete.</param>
/// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public static bool Delete(UserContactTable myUserContactTable){
return UserContactTableDB.Delete(myUserContactTable.UserContactKey);
}

#endregion

}

}
